﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 实验报告2._3
{
    class Program
    {
        static void Main(string[] args)
        {
            Triangle t = new Triangle(8, 8, 8);
            
            Console.WriteLine("三角形的周长为：{0}",t.Perimeter);
            Console.WriteLine("三角形的面积为：{0}", t.Area);
            Console.ReadKey();
        }
    }
    public class Triangle
    {
        private double a { get; set; }
        private double b{ get; set; }
        private double c{ get; set; }
        public Triangle(double a,double b,double c)
        {
            this.a = a;
            this.b = b;
            this.c = c;
            if (a > 0 && b > 0 && c > 0)
            {
                if (a + b > c && a + c > b && b + c > a)
                    Console.WriteLine("可以构成三角形");
                else
                    throw new ArgumentException(" 任意两边之和应大于第三边");  
            }
            else
            {
                throw new ArgumentException(" 边长不能为负数");
            }
        }
        public double Perimeter
        {
            get { return a + b + c; }
        
        }
        public double  Area
        {
            get
            {
                double h = (a+b+c) / 2;
                double area = Math.Sqrt(h * (h - a) * (h - b) * (h - c));
                return area;
            }
        }
    }
}
